package pl.ydp.components.mathcell.mathrecognizer.engine.database.modelsets.math_basic.characters
{
	import pl.ydp.components.mathcell.mathrecognizer.characters.Character;
	import pl.ydp.components.mathcell.mathrecognizer.geometry.classification.PrimitiveType;
	import pl.ydp.components.mathcell.mathrecognizer.model.PrimitivesRelation;
	import pl.ydp.components.mathcell.mathrecognizer.model.RelationDescription;
	import pl.ydp.components.mathcell.mathrecognizer.model.RelationDescriptorType;
	import pl.ydp.components.mathcell.mathrecognizer.model.ShapeModel;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.ConnectionsDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.LocationDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.ObjectDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.descriptors.SizeDescriptor;
	import pl.ydp.components.mathcell.mathrecognizer.model.presets.PrimitivePresets;
	public class MB_ch_3
	{
		
		public static const MODELS_COUNT:Number = 4;
		
		//---------------------------------------------------
		
		public static function getModels():Array{
			
			var threeShapeModels:Array = new Array();
			
			threeShapeModels.push(getModel0());
			threeShapeModels.push(getModel1());	
			threeShapeModels.push(getModel2());		
			threeShapeModels.push(getModel3());
			threeShapeModels.push(getModel4());
			
			return threeShapeModels;
		}
		
		//---------------------------------------------------
		
		private static function getModel0():ShapeModel{
			var three:ShapeModel;
			var name:String = "MB_3_RND";
			var three_prim:Array = new Array();
			var three_ref:Array = new Array();
			var three_rel:Array = new Array();
			
			three_prim.push(PrimitiveType.CURVE_EAST, PrimitiveType.CURVE_EAST);
			
			three_ref.push(0,1,PrimitivePresets.RLT_FULL);
			
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, ObjectDescriptor.END, ObjectDescriptor.BEGIN)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.HALF_BOTTOM, ObjectDescriptor.MAX_TOP)));
			
			three_rel.push(new RelationDescription(0,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.IS_HIGHER_THAN_QUARTER, 10)));
			
			
			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.IS_HIGHER_THAN_QUARTER, 10)));
			
			
			three = new ShapeModel(Character.THREE, three_prim, three_ref, three_rel, new Array(), name, true);
			
			return three;				
		}
		
		//---------------------------------------------------
		
		private static function getModel1():ShapeModel{
			var three:ShapeModel;
			var name:String = "MB_3_ANGLR+ANGLR";
			var three_prim:Array = new Array();
			var three_ref:Array = new Array();
			var three_rel:Array = new Array();
			
			three_prim.push(PrimitiveType.LINE0 | PrimitiveType.LINE1,  PrimitiveType.LINE3 | PrimitiveType.LINE0,PrimitiveType.LINE0 | PrimitiveType.LINE1,  PrimitiveType.LINE3 | PrimitiveType.LINE0);
			
			three_ref.push(0,1,2,3,PrimitivePresets.RLT_FULL);
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 7, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.END_EASTERN)) );

			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.HALF_BOTTOM, ObjectDescriptor.MAX_TOP)));
			
			
			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 7, 
															ObjectDescriptor.END_WESTERN, ObjectDescriptor.END_WESTERN)) );

			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.HALF_BOTTOM, ObjectDescriptor.MAX_TOP)));

			
			
			three_rel.push(new RelationDescription(2,3,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 7, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.END_EASTERN)) );

			three_rel.push(new RelationDescription(2,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.HALF_BOTTOM, ObjectDescriptor.MAX_TOP)));
			
			
			three_rel.push(new RelationDescription(3,4,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.BELOW, 1)));
			

			three = new ShapeModel(Character.THREE, three_prim, three_ref, three_rel, new Array(), name);
			
			return three;				
		}
		
		//---------------------------------------------------
		
		private static function getModel2():ShapeModel{
			var three:ShapeModel;
			var name:String = "MB_3_ANGLR+RND";
			var three_prim:Array = new Array();
			var three_ref:Array = new Array();
			var three_rel:Array = new Array();
			
			three_prim.push(PrimitiveType.LINE0 | PrimitiveType.LINE1 | PrimitiveType.LINE3 ,  PrimitiveType.LINE3 | PrimitiveType.LINE0,PrimitiveType.CURVE_EAST);
			
			three_ref.push(0,1,2,PrimitivePresets.RLT_FULL);
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 5, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.END_EASTERN)) );

			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10, ObjectDescriptor.COG, ObjectDescriptor.END_EASTERN)));
			
			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 5, 
															ObjectDescriptor.END_WESTERN, ObjectDescriptor.BEGIN)) );

			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));

			three_rel.push(new RelationDescription(1,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			
			three_rel.push(new RelationDescription(2,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.BELOW, 5)));
			
			three = new ShapeModel(Character.THREE, three_prim, three_ref, three_rel, new Array(), name, true);
			
			return three;				
		}	
			
		//---------------------------------------------------
		
		private static function getModel3():ShapeModel{
			var three:ShapeModel;
			var name:String = "MB_3_RND+ANGLR";
			var three_prim:Array = new Array();
			var three_ref:Array = new Array();
			var three_rel:Array = new Array();
			
			three_prim.push(PrimitiveType.CURVE_EAST, PrimitiveType.LINE0 | PrimitiveType.LINE1,  PrimitiveType.LINE3 | PrimitiveType.LINE0);
			
			three_ref.push(0,1,2,PrimitivePresets.RLT_FULL);
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 5, 
															ObjectDescriptor.END, ObjectDescriptor.END_WESTERN)) );

			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			three_rel.push(new RelationDescription(0,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 7)));
			
			
			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 5, 
															ObjectDescriptor.END_EASTERN, ObjectDescriptor.END_EASTERN)) );

			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10)));
			
			three_rel.push(new RelationDescription(1,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.BELOW, 7)));
			
			
			three_rel.push(new RelationDescription(2,3,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.BELOW, 7)));
			
			three = new ShapeModel(Character.THREE, three_prim, three_ref, three_rel, new Array(), name, true);
			
			return three;				
		}
		
		//---------------------------------------------------
		
		private static function getModel4():ShapeModel{
			var three:ShapeModel;
			var name:String = "MB_3_LOOP";
			var three_prim:Array = new Array();
			var three_ref:Array = new Array();
			var three_rel:Array = new Array();
			
			three_prim.push(PrimitiveType.LOOP, PrimitiveType.CURVE_EAST);
			
			three_ref.push(0,1,PrimitivePresets.RLT_FULL);
			
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.RIGHT, 10, ObjectDescriptor.DEFAULT, ObjectDescriptor.END_NORTHERN)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.RIGHT, 10, ObjectDescriptor.DEFAULT, ObjectDescriptor.END_SOUTHERN)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.LEFT, 10, ObjectDescriptor.DEFAULT, ObjectDescriptor.MAX_RIGHT)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.CONNECTION, ConnectionsDescriptor.EXIST, 10, ObjectDescriptor.END, ObjectDescriptor.BEGIN)));
			
			three_rel.push(new RelationDescription(0,1,new PrimitivesRelation(RelationDescriptorType.LOCATION, LocationDescriptor.ABOVE, 10, ObjectDescriptor.HALF_BOTTOM, ObjectDescriptor.MAX_TOP)));
			
			three_rel.push(new RelationDescription(0,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.IS_HIGHER_THAN_QUARTER, 10)));
			
			
			three_rel.push(new RelationDescription(1,2,new PrimitivesRelation(RelationDescriptorType.SIZE, SizeDescriptor.IS_HIGHER_THAN_QUARTER, 10)));
			
			
			three = new ShapeModel(Character.THREE, three_prim, three_ref, three_rel, new Array(), name, true);
			
			return three;				
		}
	}
}